﻿<!--BitAdmin2.0框架文件-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>用户登录</title>
    <meta name="description" content="BitAdminCore, Version 1.0" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <!--基础引用-->
    <link href="../../lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="../../lib/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <!--框架引用-->
    <link href="../../lib/admin-lte/css/AdminLTE.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="../../css/framework/BitAdmin.css" />
    <style type="text/css">
        .login-box-body, .form-control {
            border-radius: 2px;
        }

        .gray {
            -webkit-filter: grayscale(100%);
            -moz-filter: grayscale(100%);
            -ms-filter: grayscale(100%);
            -o-filter: grayscale(100%);
            filter: grayscale(100%);
            filter: gray;
        }
    </style>
</head>
<body class="hold-transition login-page">
    <div class="login-box">
        <div class="login-logo">
            <a href="javascript:void(0);"><b>BitAdminCore</b></a>
        </div>
        <!-- /.login-logo -->
        <div class="login-box-body">
            <h3 class="login-box-msg">用户登录</h3>
            <ul class="nav nav-tabs nav-justified">
                <li role="presentation" class="active"><a href="#t1" data-toggle="tab">账号密码</a></li>
                <li role="presentation"><a href="#t2" data-toggle="tab">手机验证</a></li>
            </ul>
            <div class="tab-content" style="padding-top:15px;">
                <div id="t1" class="tab-pane fade in active">
                    <div class="form-group has-feedback">
                        <input type="text" id="txtUserCode1" class="form-control" placeholder="帐号/手机/邮箱" value="admin">
                        <span class="glyphicon glyphicon-user form-control-feedback"></span>
                    </div>
                    <div class="form-group has-feedback">
                        <input type="password" id="txtPassword" class="form-control" placeholder="密码" value="123456">
                        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                    </div>
                    <div class="form-group row">
                        <div class="col-xs-4" style="padding-left: 15px;">
                            <input type="text" id="verifyCode" class="form-control" placeholder="验证码">
                        </div>
                        <div class="col-xs-4" style="padding-left: 15px;" id="divImg">
                            <img id="verifyCodeImage" src="../../account/verifycode" style="cursor:pointer;" title="点击刷新" />
                        </div>
                        <div class="col-xs-4" style="padding-right: 15px;">
                            <button type="button" id="btnLogin" class="btn btn-primary btn-block ">登录</button>
                        </div>
                    </div>
                </div>
                <div id="t2" class="tab-pane fade">
                    <div class="form-group has-feedback">
                        <input type="text" id="txtUserCode2" class="form-control" placeholder="帐号/手机" value="admin">
                        <span class="glyphicon glyphicon-user form-control-feedback"></span>
                    </div>
                    <div class="form-group row">
                        <div class="col-xs-6" style="padding-left: 15px;">
                            <input type="text" id="smsCode" class="form-control" placeholder="验证码">
                            <input type="hidden" id="smsSign" />
                        </div>
                        <div class="col-xs-6" style="padding-right: 15px;">
                            <button type="button" id="smsSend" class="btn btn-primary btn-block ">发送验证短信</button>
                        </div>
                    </div>
                    <div class="form-group has-feedback">
                        <button type="button" id="smsLogin" class="btn btn-primary btn-block " disabled>短信验证登录</button>
                    </div>
                </div>
            </div>
            <div class="clearfix"></div>
            <div class="form-group has-feedback">
                <span id="spanmsg" style="color:red;"></span>
            </div>
            <div class="row" style="padding-left:15px;padding-top:5px;">
                使用第三方账号登录
            </div>
            <div class="row" style="padding-left:8px;">
                <a href="https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=101107448&redirect_uri=https%3A%2F%2Fwww.bitadmincore.com%2Fauth%2Fqqsignin&scope=">
                    <img style="width:48px;" src="../../images/account/qq.png" />
                </a>
                <a href="https://open.weixin.qq.com/connect/qrconnect?appid={0}&redirect_uri=https%3A%2F%2Fwww.bitadmincore.com%2Fauth%2Fweixinsignin&response_type=code&scope=snsapi_login&state=#wechat_redirect">
                    <img style="width:48px;" class="gray" src="../../images/account/weixin.png" />
                </a>
            </div>
        </div>
        <!-- /.login-box-body -->
    </div>
    <!--基础引用-->
    <script src="../../lib/jquery/jquery.min.js"></script>
    <script src="../../lib/bootstrap/js/bootstrap.min.js"></script>
    <!--组件引用-->
    <script src="../../lib/jquery-validation/jquery.validate.min.js"></script>
    <script src="../../lib/jquery-form/jquery.form.min.js"></script>
    <!--框架引用-->
    <script type="text/javascript" src="../../js/framework/BitAdmin.js"></script>

    <script type="text/javascript" src="../../js/tracking/tracking-min.js"></script>
    <script type="text/javascript" src="../../js/tracking/face-min.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            if (self.frameElement && self.frameElement.tagName === "IFRAME") {
                parent.location = this.location;
            }
            BitAdmin.IsLogin(function () {
                //window.location.href = "http://www.example.com/login.html"; //外部登录时启用
            }, "login");

            //账号密码登录
            $("#verifyCodeImage").click(function () {
                $(this).attr("src", "../../account/verifycode?_" + Math.random());
            });

            $("#btnLogin").click(function () {
                var account = $("#txtUserCode1").val();
                if (account === "") {
                    $("#spanmsg").text("请输入帐号/手机/邮箱");
                    return;
                }
                var password = $("#txtPassword").val();
                if (password === "") {
                    $("#spanmsg").text("请输入登录密码");
                    return;
                }
                var verifyCode = $("#verifyCode").val();
                if (verifyCode === "") {
                    $("#spanmsg").text("请输入验证码");
                    return;
                }

                $.showLoading();
                $.ajax({
                    url: "../../account/login",
                    data: { account: account, password: password, verifyCode: verifyCode },
                    datatype: "json",
                    type: "post",
                    success: function (result) {
                        if (result.code === 0) {
                            BitAdmin.RedirectToHomePage();
                        } else {
                            $("#spanmsg").text(result.msg);
                            $("#txtPassword").val('');
                            $("#verifyCodeImage").attr("src", "../../account/verifycode?_" + Math.random());
                        }
                        $.hideLoading();
                    },
                    error: function (a, b, c) {
                        alert(a.responseText);
                        $.hideLoading();
                    }
                });
            });
            $("#verifyCode").bind('keypress', function (event) { if (event.keyCode === 13) { $("#btnLogin").click(); } });

            //手机验证登录
            $("#smsSend").click(function () {
                $("#spanmsg").text("");
                var account = $("#txtUserCode2").val();
                if (account === "") {
                    $("#spanmsg").text("请输入账号/手机/邮箱");
                    return;
                }
                settime();
                var sign = Math.random();
                $("#smsSign").val(sign);
                $.get("../../account/smscode", { account: account, t: sign }, function (result) {
                    if (result.code === 0) {
                        $("#smsLogin").attr('disabled', false);
                    } else {
                        countdown = 0;
                        $("#spanmsg").text("发送失败，请重新发送");
                    }
                });
            });
            $("#smsLogin").click(function () {
                var account = $("#txtUserCode2").val();
                if (account === "") {
                    $("#spanmsg").text("请输入账号/手机/邮箱");
                    return;
                }
                var smsCode = $("#smsCode").val();
                if (smsCode === "") {
                    $("#spanmsg").text("请输入验证码");
                    return;
                }
                $.showLoading();
                $.get("../../account/smslogin", { account: account, t: $("#smsSign").val(), code: smsCode }, function (result) {
                    if (result.code === 0) {
                        BitAdmin.RedirectToHomePage();
                    } else {
                        countdown = 0;
                        $("#smsCode").val('');
                        $("#smsSend").attr('disabled', false);
                        $("#spanmsg").text(result.msg);
                    }
                    $.hideLoading();
                });
            });

            var countdown = 5;
            function settime() {
                if (countdown === 0) {
                    $("#smsSend").attr('disabled', false);
                    $("#smsSend").text("发送验证短信");
                    countdown = 60;
                    return;
                } else {
                    $("#smsSend").attr('disabled', true);
                    $("#smsSend").text("重新发送(" + countdown + ")");
                    countdown--;
                    setTimeout(settime, 1000);
                }
            }
        });
    </script>
</body>
</html>
